package personresources.manager.managedbean;

import java.util.List;

import javax.faces.event.PhaseEvent;
import javax.faces.model.SelectItem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import personresources.manager.dto.EmployeeDto;
import personresources.manager.hibernate.Employee;
import personresources.manager.hibernate.Group;
import personresources.manager.logic.EmployeeLogic;
import personresources.manager.logic.GroupLogic;
@Component("employeeListManaged")
@Scope("request")
public class EmployeeListManaged {
	private static final String SCREEN_SEARCH_EMPLOYEE = "searchEmployees";
	private int groupId;
	private int numberOne;
	private int numberTwo;
	private int sumResult;
	private List<EmployeeDto> lsEmployeeDto;
	private List<SelectItem> lsGroup;
	@Autowired 
	private EmployeeLogic employeeLogic;
	@Autowired
	private GroupLogic groupLogic;
	public EmployeeListManaged(){
	}
	
	public void doInitPage(PhaseEvent event) {
		
	}
	/**
	 * do find Employees by selected group
	 * @return Screen search page
	 */ 
	public String doFind() throws Exception{
		
		Employee e = new Employee();
		e.setEmployeeName("ChuongHD");
		e.setEmployeeEmail("aaa");
	//	e.setEmployeePhoneNumber("asdasf");
		lsEmployeeDto = employeeLogic.getEmployeeList(groupId);
		lsGroup = groupLogic.getGroupSelectItemList();
		List<Group> groups = (List<Group>)groupLogic.getGroupList();
		e.setGroup(groups.get(0));
		employeeLogic.setEmployee(e);
		//throw new Exception(Message.getString("passwordRequired")); 
		return SCREEN_SEARCH_EMPLOYEE;
	}

	/**
	 * Add method
	 * @return Screen
	 */
	public String doAdd() {
		sumResult = numberOne + numberTwo;
		return "";
	}
	public List<EmployeeDto> getLsEmployeeDto() {
		return lsEmployeeDto;
	}

	public void setLsEmployeeDto(List<EmployeeDto> lsEmployeeDto) {
		this.lsEmployeeDto = lsEmployeeDto;
	}

	public List<SelectItem> getLsGroup() {
		return lsGroup;
	}

	public void setLsGroup(List<SelectItem> lsGroup) {
		this.lsGroup = lsGroup;
	}

	public void setGroupId(int groupId) {
		this.groupId = groupId;
	}

	public int getGroupId() {
		return groupId;
	}

	public void setNumberTwo(int numberTwo) {
		this.numberTwo = numberTwo;
	}

	public int getNumberTwo() {
		return numberTwo;
	}

	public void setNumberOne(int numberOne) {
		this.numberOne = numberOne;
	}

	public int getNumberOne() {
		return numberOne;
	}

	public void setSumResult(int sumResult) {
		this.sumResult = sumResult;
	}

	public int getSumResult() {
		return sumResult;
	}
	
	
}
